<?php
/**
 * Class representation of the HTML <input type="password" /> tag. It can be added to containers.
 *
 * @author Niels Janssen
 * @since 2008-07-08
 * @package Form.Elements
 */
class InputPassword extends FormElement {

	/**
	 * Constructor for the TextField class, passes variables to the FormElement constructor.
	 *
	 * @param String $name
	 */
	public function __construct( $name, $label = '', $value = '', $properties = array( ) )
	{
		parent::__construct( $name, array_merge( array( 'label' => $label, 'value' => $value ), $properties ) );
	}

	/**
	 * @see FormElement::__toString()
	 */
	public function __toString() {
		return '
			<div class="'.( $this->getProperty("class") != '' ? $this->getProperty("class") : 'form inputpassword' ).'">
				<label for="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '">' . $this->getProperty("label") . '</label>
				<input type="password" name="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '" id="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '" value="' . $this->value . '"' . ( $this->getProperty( 'tabindex' ) ? ( ' tabindex="' . $this->getProperty( 'tabindex' ) . '"' ) : '' ) . ' />
				' . ( $this->inAJAXMode() || !empty( $this->errorMessage ) ? '<div class="error' . ( $this->inAJAXMode() ? ' ajax' : '' ) . '" id="' . ( $this->getFormName() != '' ? $this->getFormName() . '_' : '' ) . $this->name . '_error">' . $this->errorMessage . '</div>' : '' ) . '</div>';
	}
}

?>